 
    //导航头部
if ($(".swiper_nav .swiper-container .swiper-slide").size() >= 1) {
    var side = 7;
    var swiper_nav = new Swiper('.swiper_nav .swiper-container', {
        slidesPerView: 'auto',
    });
    $(".swiper_nav .swiper-container .swiper-slide").each(function (index) {
        if ($(this).hasClass("on") && index > 4) {
            var index_ = $(this).index();
            swiper_nav.slideTo(index_, false);//切换到第一个slide，速度为1秒;
        }
    })
}
    //首页的轮播
    if ($(".swiper_lunbox .swiper-container .swiper-slide").size() >= 1) {
        var swiper = new Swiper('.swiper_lunbox .swiper-container', {
            lazy: {
                loadPrevNext: true,
            },
            observer:true,
            observeParents:true,
            speed: 200,
            autoplay: {
                delay: 4000,
                disableOnInteraction: false,
            },
            pagination: {
                el: '.swiper_lunbox .swiper-pagination',
                clickable: true,
            },

        });
    }
    //知识专区头图
    if ($(".Minzqswiper .swiper-container .swiper-slide").size() >1) {
        var swiper = new Swiper('.Minzqswiper .swiper-container', {
            lazy: {
                loadPrevNext: true,
            },
            observer:true,
            observeParents:true,
            speed: 200,
            autoplay: {
                delay: 4000,
                disableOnInteraction: false,
            },
        });
    }
if ($(".swiperautotab  .swiper-slide").size() >= 1) {
    var swiperautotab = new Swiper('.swiperautotab', {
        observer:true,
        observeParents:true,
        slidesPerView: 'auto',
    });
    $(".swiperautotab  .swiper-slide").each(function (index) {
        if ($(this).hasClass("on") && index > 4) {
            var index_ = $(this).index();
            swiperautotab.slideTo(index_, false);//切换到第一个slide，速度为1秒;
        }
    })
}

if ($(".swipergrid  .swiper-slide").size() >= 1) {
    var swipergrid = new Swiper('.swipergrid', {
        observer:true,
        observeParents:true,
        slidesPerView: 5,
        slidesPerColumn : 2,
        // slidesPerColumnFill : 'column',
        pagination: {
            el: '.swiperpagination',
            type : 'progressbar',
        },
    });
  
}






// swiper  auto
if($(".swiperauto .swiper-slide").size()>=1){
    var swiperauto = new Swiper(".swiperauto.swiper-container", {
        slidesPerView: 'auto',
        observer:true,
        observeParents:true,
        lazy: {
            loadPrevNext: true,
            loadPrevNextAmount: 5,
        },
        });
}
// Min4auto
if($(".Min4 .swiper-slide").size()>=1){
    var Min4swide=5;
    if($(".Min4").parents(".Minbox_rit").size()>=1){
        Min4swide=4
    }
    var Min4swiper = new Swiper(".Min4 .swiper-container", {
        slidesPerView: Min4swide,
        lazy: {
            loadPrevNext: true,
            loadPrevNextAmount: 5,
        },
        });
}
  // 切换click
  $(".switchwarp-ck .switchlabe .tab").click(function() {
    $(this).addClass('on').siblings().removeClass('on');
    var i=$(this).index();
    $(this).parents(".switchwarp-ck").find(".switchbox .switchitem ").eq(i).show().siblings().hide();
    $(this).parents(".switchwarp-ck").find(".switchmore a").eq(i).show().siblings().hide();
    $(window).trigger('scroll');
  })
    // 二级切换click
    $(".switchwarp-ck2 .switchlabe2 .tab").click(function() {
        $(this).addClass('on').siblings().removeClass('on');
        var i=$(this).index();
        $(this).parents(".switchwarp-ck2").find(".switchbox2 .switchitem2 ").eq(i).show().siblings().hide();
        $(window).trigger('scroll');
      })
    // 游戏截图
function scroll_img_height(){
    var box=$(".swiperimgbox .swiper-container .swiper-slide").eq(1).find("img");
    var imgo = new Image();
        imgo.src = box.attr('src');
        var slidesPerView=1.1;
        imgo.onload=function(){
            var img_h=imgo.height;
            var img_w=imgo.width;
            if (img_h>img_w){
                $(".swiperimgbox").addClass("swiperimg_h")
                 slidesPerView=1.9;
            }
            var swiperimgbox = new Swiper(".swiperimgbox .swiper-container", {
                slidesPerView: slidesPerView,
                observer:true,
                spaceBetween: 13,
                lazy: {
                    loadPrevNext: true,
                },
                navigation: {
                    nextEl: ".swipernext",
                    prevEl: ".swiperprev",
                },
            });
        }
}
if($(".swiperimgbox .swiper-slide").size()>=1){
  var time_ = window.setTimeout("scroll_img_height()",500);//使用字符串执行方法;
}
  //下载锚点定位
$(".scrollckbox .li").click(function(){
    var box =$(this).attr("data-id")
    var nav_num = $("#"+box).offset().top;
    $("body,html").animate({scrollTop:nav_num},300);
})
 
	// 放大图片
if($('.swiperimgbox ').length>0 || $('.details_html img').length>0){
    var pswpHtml = '';
    pswpHtml +='<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true"><div class="pswp__bg"></div><div class="pswp__scroll-wrap"><div class="pswp__container"><div class="pswp__item"></div><div class="pswp__item"></div><div class="pswp__item"></div></div><div class="pswp__ui pswp__ui--hidden"><div class="pswp__top-bar"><div class="pswp__counter"></div><button class="pswp__button pswp__button--close" title="Close (Esc)"></button><button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button><button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button><div class="pswp__preloader"><div class="pswp__preloader__icn"><div class="pswp__preloader__cut"><div class="pswp__preloader__donut"></div></div></div></div></div><button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)"></button><button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)"></button><div class="pswp__caption"><div class="pswp__caption__center"></div></div></div></div></div>'
     $("body").append(pswpHtml);
     function pswpFun(els){
        if(els.length>0){
            els.find('p > img').on('click',function(){
                    var pswpElement = document.querySelectorAll('.pswp')[0];
                var items = new Array();
                $.each(els.find('p > img'), function(i, v) {
                        $(v).attr("rel", i);
                    items.push({
                        src: $(v).attr("src"),
                        w: $(v).width(),
                        h: $(v).height()
                    });
                });
                var options = { index: parseInt($(this).attr("rel")) };
                var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, options);
        
                if($(this).parents("a").length>0){
                       return;
                   }else{
                       gallery.init();
                   }
            });
        }
    }
    pswpFun($('.details_html '));
    if($('.swiperimgbox').length>0){
        $('.swiperimgbox').find('img').on('click',function(){
                var pswpElement = document.querySelectorAll('.pswp')[0];
            var items = new Array();
            $.each($('.swiperimgbox').find('img'), function(i, v) {
                    $(v).attr("rel", i);
                items.push({
                       src: $(v).attr("src"),
                       w: $(v).width(),
                       h: $(v).height()
                });
            });
            var options = { index: parseInt($(this).attr("rel")) };
            var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, options);
               gallery.init();
        });
    }
    
}

// 正文查看更多
if($(".seemore").size()>=1){
    var seemore_h=$(".seemore").height();
    var h=281;
    if($(".seemore").hasClass("height3")){
        h=85;
    }
    if(seemore_h>h){
        $(".seemore").addClass("autoheight");
        $(".seemore").append('<div class="more_text">展开</div>')
    }
    $(".seemore .more_text").click(function(){
        $(".seemore").removeClass("autoheight");
        $(this).remove();
    })
}
  //阻止事件冒泡
  function stopNextEvent(evt) {
    var e = (evt) ? evt : window.event;
    if (window.event) {
        e.cancelBubble = true;// ie下阻止冒泡
    } else {
        //e.preventDefault();
        e.stopPropagation();// 其它浏览器下阻止冒泡
    }
}
$("body").click(function(obj, evt){
    $(".selectbox .select ul").css("cssText", "display:none !important");
  })
  $(".selectbox .select .bt").click(function(obj, evt){
        stopNextEvent(evt);
        $(".selectbox .select ul").css("cssText", "display:none !important");
        $(this).parents(".select").find("ul").show();
  })
// 列表页面时间的筛选
function timescreen(){
    //执行一个laydate实例
    var date = new Date();
    var year = date.getFullYear();
    var month = date.getMonth() + 1;
    var day = date.getDate();
    month = (month > 9) ? month : ("0" + month);
    day = (day < 10) ? ("0" + day) : day;
    var today = year + "/" + month + "/" + day;
    $(".calendar .input").val(today)
    laydate.render({
      elem: '#calendar', //指定元素,
      done:function(value, date, endDate){
        console.log(value); //得到日期生成的值，如：2017-08-18
        $(".calendar .input").val(value)
      }
    });
 }
 if($(".calendar").size()>=1){
    timescreen()
 }
 // UP回到顶部
$("body").append("<div class='QZ-up icon'></div>")
$(window).scroll(function () {
    var scroll_len = $(window).scrollTop();
    if (scroll_len > 120) {
        $('.QZ-up').fadeIn();
    } else {
        $('.QZ-up').fadeOut();
    }
});
$('.QZ-up').click(function () {
    $("body,html").animate({ scrollTop: 0 }, 300);
});


// 列表页面的点击显示更多分类
$(" .addmoreli").each(function(){
    let that=$(this);
    if(that.find("li").size()>12){
      that.find("li:gt(10)").hide();
      that.append('<li class="more on"><a><span>展开</span><i class="icon icojt3"></i></a></li>')
      that.find("li.more").show()
    }
    that.find("li.more").click(function(){
      if($(this).hasClass("active")){
        that.find("li:gt(10)").hide();
        that.find("li.more").show()
        that.find("li.more span").text('展开')
      }else{
        that.find("li").show()
        that.find("li.more span").text('收起')
      }
      $(this).toggleClass("active")
    })
  })

    //阻止事件冒泡
function stopNextEvent(evt) {
    var e = (evt) ? evt : window.event;
    if (window.event) {
        e.cancelBubble = true;// ie下阻止冒泡
    } else {
        //e.preventDefault();
        e.stopPropagation();// 其它浏览器下阻止冒泡
    }
}

$(" .search_text .tab .bt").click(function(obj, evt){
    stopNextEvent(evt);
    $(".search_text .tab .lis").css("cssText", "display:none !important");
    $(this).parents(".tab").find(".lis").show();
})
$("body").click(function(){
    $(".search_text .tab .lis").css("cssText", "display:none !important");
})

// 播放语音
if($(".audiotext").size()>=1){
    var messagevideo = new SpeechSynthesisUtterance();
    messagevideo.lang = 'zh-CN';
    messagevideo.rate = 0.5;
    $(".audiotext .icon").click(function(){
        let text=$(this).parents(".audiotext").find("span").text();
        $(this).addClass("on")
        console.log(text)
        messagevideo.text=text;
        speechSynthesis.speak(messagevideo);
    })
    messagevideo.addEventListener('end', ()=>{
        $(".audiotext .icon").removeClass("on")
    });
    
}


